<?php
require __DIR__ . '/../vendor/autoload.php';

use App\Core\Router;

// 示例路由
Router::get('', function() {
    echo "Welcome to the MVC Framework!";
});

// Router::get('test', ['App\Controllers\TestController', 'index'], ['App\Middleware\AuthMiddleware']);

Router::get('test', ['App\Controllers\TestController', 'index']);

// 捕获异常并处理
try {
    Router::dispatch();
} catch (Exception $e) {
    http_response_code($e->getCode() ?: 500);
    echo $e->getMessage();
}